package com.shasselclub.common.utils;

public class UrlUtils {
    /**
     * 去除url指定参数
     * 使用
     * 例: https://www.lyf.com/user/info?uid=1&enc=88182&id=1001&t=1597372964477
     * removeParam(url, "enc", "id");
     * 结果: https://www.lyf.com/user/info?uid=1&t=1597372964477
     * @param url
     * @param name
     * @return
     */
    public static String removeParam(String url, String ...name){
        for (String s : name) {
            // 使用replaceAll正则替换,replace不支持正则
            url = url.replaceAll("&?"+s+"=[^&]*","");
        }
        return url;
    }
}
